<?php
/**
 * Created by PhpStorm.
 * User: lx
 * Date: 2020/1/13
 * Time: 14:23
 */
namespace app\mtsuperadmin\controller;

use think\Controller;

class Base extends Controller
{
    /**
     * Error
     * @param $code
     * @param string $msg
     * @param array $data
     * @return array
     */
    public function bindError($code, $msg = '操作失败', $data = []){
        $return = [
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ];
        Hook::listen("AdminApiRequest",['code' => $code,'msg' => $msg]);
        return $return;
    }

    /**
     * Success
     * @param string $msg
     * @param array $data
     * @param int $code
     * @return array
     */
    public function bindSuccess($msg = '操作失败', $data = [], $code = ReturnCode::SUCCESS){
        $return = [
            'code' => $code,
            'msg'  => $msg,
            'data' => $data
        ];
        Hook::listen("AdminApiRequest",['code' => $code,'msg' => $msg]);
        return $return;
    }
}